import time

#装饰器函数
def deco_time(fun):

    def time_diff():
        #开始时间
        start_time = time.time()
        #执行函数
        fun()
        #结束时间
        end_time = time.time()
        print("运行时间为：")
        #时间差
        duration_time=end_time-start_time
        print(duration_time)

    return time_diff

@deco_time
#自定义函数
def add_num():
    time.sleep(1)#程序休眠1秒
    sum = 0
    for i in range(0,100):
        sum=sum+i
    print(sum)

add_num()



